/**
 *
 * @description:
 * @author: junyong.hong
 * @createTime: 2019/4/30
 * @version: 1.0.0.0
 * @history:
 *    1、
 *    2、
 *
 */
import Router from 'koa-router';
// import axios from './utils/axios'
// import Province from '../dbs/models/province'
import Categroy from '../dbs/models/categroy'
import sign from './utils/sign'
let router = new Router({prefix: '/categroy'})

router.get('/crumbs',async (ctx)=>{
  const result = await Categroy.findOne({
    city: ctx.query.city
  })
  if (result) {
    ctx.body = {
      areas: result.areas,
      types: result.types
    }
  } else {
    ctx.body = {
      areas: [],
      types: []
    }
  }

  // let {status,data:{areas,types}} = await axios.get('http://cp-tools.cn/categroy/crumbs',{
  //   params:{
  //     city:ctx.query.city.replace('市','') || "北京",
  //     sign
  //   }
  // })
  // ctx.body={
  //   areas: status===200?areas:[],
  //   types: status===200?types:[]
  // }
})


export default router
